/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fuzzy.actions;

import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author michal
 */
public class ClientActionForm extends org.apache.struts.action.ActionForm {
    
    private BigDecimal clientId;
    private String username;
    private String password;
    private String firstname;
    private String lastname;
    private String pesel;
    private String address;
    private boolean sent = false;

    /**
     *
     */
    public ClientActionForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getUsername() == null || getUsername().length() < 1) {
            errors.add("name", new ActionMessage("error.username.required"));
        }
        
        if (getPassword() == null || getPassword().length() < 1) {
            errors.add("name", new ActionMessage("error.password.required"));
        }
        
        if (getFirstname() == null || getFirstname().length() < 1) {
            errors.add("name", new ActionMessage("error.firstname.required"));
        }
        
        if (getLastname() == null || getLastname().length() < 1) {
            errors.add("name", new ActionMessage("error.lastname.required"));
        }
        
        if (getPesel() == null || getPesel().length() < 1) {
            errors.add("name", new ActionMessage("error.pesel.required"));
        }
        
        if (getAddress() == null || getAddress().length() < 1) {
            errors.add("name", new ActionMessage("error.address.required"));
        }
        return errors;
    }

    /**
     * @return the firstname
     */
    public String getFirstname() {
        return firstname;
    }

    /**
     * @param firstname the firstname to set
     */
    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    /**
     * @return the lastname
     */
    public String getLastname() {
        return lastname;
    }

    /**
     * @param lastname the lastname to set
     */
    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    /**
     * @return the pesel
     */
    public String getPesel() {
        return pesel;
    }

    /**
     * @param pesel the pesel to set
     */
    public void setPesel(String pesel) {
        this.pesel = pesel;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the clientId
     */
    public BigDecimal getClientId() {
        return clientId;
    }

    /**
     * @param clientId the clientId to set
     */
    public void setClientId(BigDecimal clientId) {
        this.clientId = clientId;
    }

    /**
     * @return the sent
     */
    public boolean isSent() {
        return sent;
    }

    /**
     * @param sent the sent to set
     */
    public void setSent(boolean sent) {
        this.sent = sent;
    }
}
